package com.sample.rx3.libs.rxjava;

import com.loyal.client.RxConfig;

import java.util.HashMap;
import java.util.Map;

public final class ApiConfig {

    public static final String HTTP = "http";
    public static final String HTTPS = "https";
    public static final String BASEURL = "baseUrl";
    public static final String NAMESPACE = "app";
    public static final String NAMESPACE_SYSTEM = "system";

    public static final String DEFAULT_IP = "1.2.3.4";
    public static final String DEFAULT_PORT = "9081";

    public static final class Key {
        public static final String URL = "apiUrl";
    }

    public static RxConfig config() {
        RxConfig rxConfig = RxConfig.getInstance();
        rxConfig.setHttpOrHttps(HTTP);
        rxConfig.setUrl(DEFAULT_IP);
        rxConfig.setPort(DEFAULT_PORT);
        rxConfig.setNameSpace(NAMESPACE);
        return rxConfig;
    }

    public static RxConfig systemConfig() {
        RxConfig rxConfig = config();
        rxConfig.setNameSpace(NAMESPACE_SYSTEM);
        return rxConfig;
    }

    /**
     * 注册信息
     *
     * @param name           用户姓名,如：赵六
     * @param mobile         电话号码,如：13512345678
     * @param password       密码,如：123456
     * @param invitationCode 邀请码,如：F9F00048K2
     * @param smsCode        验证码,如：123456
     */
    public static Map<String, String> registerMap(String name, String mobile,
                                                  String smsCode, String password,
                                                  String invitationCode) {
        Map<String, String> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("name", name);
        map.put("password", password);
        map.put("invitationCode", invitationCode);
        map.put("smsCode", smsCode);
        return map;
    }

    /**
     * 重置密码
     *
     * @param mobile   电话号码,如：13512345678
     * @param password 密码,如：123456
     * @param smsCode  验证码,如：123456
     */
    public static Map<String, String> resetPsw(String mobile, String smsCode, String password) {
        Map<String, String> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("password", password);
        map.put("smsCode", smsCode);
        return map;
    }

    /**
     * 登录信息
     *
     * @param mobile   电话号码,如：13312345678
     * @param password 登录密码,如：147258
     */
    public static Map<String, String> loginMap(String mobile, String password) {
        Map<String, String> map = new HashMap<>();
        map.put("mobile", mobile);
        map.put("password", password);

        return map;
    }

    /**
     * 登录信息
     *
     * @param userId   用户ID,如：9f01854e00e6e5661366301a50f8cbb7
     * @param mobile   获赠者电话号码,如：13512345678
     * @param integral 赠送积分,如：10000
     */
    public static Map<String, String> transferMap(String userId, String mobile, String integral) {
        Map<String, String> map = new HashMap<>();
        map.put("userId", userId);
        map.put("mobile", mobile);
        map.put("integral", integral);
        return map;
    }

}